/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.impl;

import picounit.DelegateTestResult;
import picounit.DelegatingTestResult;
import previous.picounit.Should;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;

public class DelegatingTestResultTest implements previous.picounit.Test {
	private final DelegatingTestResult delegatingTestResult;
	private final DelegateTestResult delegateTestResult;

	private final Should should;

	private final Test test = new TestCase() {};
	private final Throwable throwable = new Throwable();
	private final AssertionFailedError assertionFailedError = new AssertionFailedError();

	public DelegatingTestResultTest(DelegateTestResult mockDelegateTestResult, Should should) {
		this.delegatingTestResult = new DelegatingTestResult(mockDelegateTestResult);

		this.delegateTestResult = mockDelegateTestResult;	

		this.should = should;
	}

	public void shouldDelegateToStartTest() {
		delegateTestResult.startTest(test);

		should.expectAboveWhenTheFollowingOccurs();

		delegatingTestResult.startTest(test);
	}

	public void shouldDelegateToEndTest() {
		delegateTestResult.endTest(test);

		should.expectAboveWhenTheFollowingOccurs();

		delegatingTestResult.endTest(test);
	}

	public void shouldDelegateToAddError() {
		delegateTestResult.addError(test, throwable);

		should.expectAboveWhenTheFollowingOccurs();

		delegatingTestResult.addError(test, throwable);
	}

	public void shouldDelegateToAddFailure() {
		delegateTestResult.addFailure(test, assertionFailedError);

		should.expectAboveWhenTheFollowingOccurs();

		delegatingTestResult.addFailure(test, assertionFailedError);
	}
}
